<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<script type="text/javascript" src="js/apply_manage/audit_apply.js"></script>
<s:if test="#session.deptNo gt '200' && #session.postNo == '002'">
	<script type="text/javascript" src="js/print_plugin/LodopFuncs.js"></script>
	<object id="LODOP_OB"
		classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
		<embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed>
	</object>
	<script type="text/javascript">
		var LODOP; //声明为全局变量

		function print_Apply_Preview() {

			LODOP = getLodop(document.getElementById('LODOP_OB'), document
					.getElementById('LODOP_EM'));
			LODOP.PRINT_INIT("打印支付申请书");

			LODOP.SET_PRINT_PAGESIZE(2, 0, 0, "A4");
			CreateAllPages();

			LODOP.SET_SHOW_MODE("LANDSCAPE_DEFROTATED", 1);
			//LODOP.PRINT_SETUP();

		}

		function CreateAllPages() {
			var iCurLine = 190;
			var fsubSumvalue = 0;
			var j = 1;

			AddTitle();
			AddTable();
			AddFooter();

			var data = $("#apply_data");
			var select = data.jqGrid('getGridParam', 'selarrrow');
			var applyNoList = "";
			$.each(select, function(i, n) {
				var ret = data.jqGrid('getRowData', n);
				applyNoList += ret.applyNo + ":";

			});

			$.ajax({
				type : "post",
				url : "apply/printApply.action",
				data : {
					"applyNos" : applyNoList
				},

				success : function(data, textStatus) {
					fillData(data);
					LODOP.PREVIEW();
				},
				complete : function(XMLHttpRequest, textStatus) {
				},
				error : function() {
				}
			});

			function fillData(data) {
				var obj = eval(data);
				var applyIndexs = obj.applyIndexes;
				for (var i = 0; i < applyIndexs.length; i++) {
					LODOP.ADD_PRINT_TEXT(iCurLine, 95, 110, 20,
							applyIndexs[i].applyNo);
					LODOP.ADD_PRINT_TEXT(iCurLine, 170, 110, 20,
							applyIndexs[i].budgetUnit);
					LODOP.ADD_PRINT_TEXT(iCurLine, 280, 110, 20,
							applyIndexs[i].payMethod);
					LODOP.ADD_PRINT_TEXT(iCurLine, 365, 120, 20,
							applyIndexs[i].funcType);
					LODOP.ADD_PRINT_TEXT(iCurLine, 505, 120, 20,
							applyIndexs[i].financialType);
					LODOP.ADD_PRINT_TEXT(iCurLine, 655, 110, 20,
							applyIndexs[i].budgetItem);
					LODOP.ADD_PRINT_TEXT(iCurLine, 730, 110, 20,
							applyIndexs[i].purpose);
					LODOP.ADD_PRINT_TEXT(iCurLine, 920, 110, 20,
							applyIndexs[i].money);
					iCurLine = iCurLine + 50;

					//合计金额
					fsubSumvalue = fsubSumvalue
							+ parseFloat(applyIndexs[i].money);

					if (j % 8 == 0 || j == applyIndexs.length) { //j表示每页只打印8条记录
						LODOP.ADD_PRINT_TEXT(595, 950, 200, 20, fsubSumvalue
								.toFixed(2));
						LODOP.ADD_PRINT_TEXT(595, 280, 500, 20, LODOP.FORMAT(
								"UpperMoney", fsubSumvalue));

						LODOP.NewPageA();
						AddTitle();
						AddTable();
						AddFooter();
						iCurLine = 190;
						fsubSumvalue = 0;
					}
					j = j + 1;
				}
			}

			function AddTitle() {
				//添加头部
				LODOP.ADD_PRINT_TEXT(70, 450, 400, 30, "财政惠农资金直接支付申请书");
				LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
				LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
				LODOP.ADD_PRINT_TEXT(95, 80, 200, 20, "申请单位名称（盖章）：");
				LODOP.ADD_PRINT_TEXT(95, 880, 150, 20, "申请日期："
						+ (new Date()).toLocaleDateString());

				LODOP.ADD_PRINT_TEXT(140, 85, 80, 20, "申请编号");
				LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
				LODOP.ADD_PRINT_TEXT(140, 180, 100, 20, "预算单位");
				LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
				LODOP.ADD_PRINT_TEXT(140, 275, 95, 20, "支付方式");
				LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
				LODOP.ADD_PRINT_TEXT(140, 380, 110, 20, "功能分类");
				LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
				LODOP.ADD_PRINT_TEXT(140, 520, 100, 20, "经济分类");
				LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
				LODOP.ADD_PRINT_TEXT(140, 640, 100, 20, "预算项目");
				LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
				LODOP.ADD_PRINT_TEXT(140, 790, 100, 20, "用途");
				LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
				LODOP.ADD_PRINT_TEXT(140, 925, 100, 20, "金额（元）");
				LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
			}

			function AddTable() {
				//表格画矩形
				LODOP.ADD_PRINT_SHAPE(2, 120, 80, 950, 500, 0, 2, "#000000");
				//矩形中横线
				LODOP.ADD_PRINT_SHAPE(0, 180, 80, 950, 1, 0, 1, "#000000");
				LODOP.ADD_PRINT_SHAPE(0, 230, 80, 950, 1, 0, 1, "#000000");
				LODOP.ADD_PRINT_SHAPE(0, 280, 80, 950, 1, 0, 1, "#000000");
				LODOP.ADD_PRINT_SHAPE(0, 330, 80, 950, 1, 0, 1, "#000000");
				LODOP.ADD_PRINT_SHAPE(0, 380, 80, 950, 1, 0, 1, "#000000");
				LODOP.ADD_PRINT_SHAPE(0, 430, 80, 950, 1, 0, 1, "#000000");
				LODOP.ADD_PRINT_SHAPE(0, 480, 80, 950, 1, 0, 1, "#000000");
				LODOP.ADD_PRINT_SHAPE(0, 530, 80, 950, 1, 0, 1, "#000000");
				LODOP.ADD_PRINT_SHAPE(0, 580, 80, 950, 1, 0, 1, "#000000");
				//矩形中竖线
				LODOP.ADD_PRINT_SHAPE(1, 120, 160, 1, 460, 0, 1, "#000000");
				LODOP.ADD_PRINT_SHAPE(1, 120, 270, 1, 500, 0, 1, "#000000");
				LODOP.ADD_PRINT_SHAPE(1, 120, 350, 1, 460, 0, 1, "#000000");
				LODOP.ADD_PRINT_SHAPE(1, 120, 490, 1, 460, 0, 1, "#000000");
				LODOP.ADD_PRINT_SHAPE(1, 120, 630, 1, 460, 0, 1, "#000000");
				LODOP.ADD_PRINT_SHAPE(1, 120, 720, 1, 500, 0, 1, "#000000");
				LODOP.ADD_PRINT_SHAPE(1, 120, 900, 1, 500, 0, 1, "#000000");
			}
			function AddFooter() {
				//添加页脚
				LODOP.ADD_PRINT_TEXT(595, 90, 200, 20, "合计（大写）");
				LODOP.ADD_PRINT_TEXT(595, 800, 200, 20, "（小写）");

				LODOP.ADD_PRINT_TEXT(635, 80, 200, 20, "本次资金发放村数：");
				LODOP.ADD_PRINT_TEXT(635, 400, 200, 20, "本次资金发放户数：");

				LODOP.ADD_PRINT_TEXT(660, 80, 200, 20, "收款人帐号：3710604");
				LODOP.ADD_PRINT_TEXT(660, 400, 200, 20, "开户银行：中国人民银行静宁县支行");
				LODOP.ADD_PRINT_TEXT(660, 700, 400, 20, "全称：国库待结算款项静宁县惠农补贴发放户");

				LODOP.ADD_PRINT_TEXT(685, 80, 200, 20, "预算单位经办：");
				LODOP.ADD_PRINT_TEXT(685, 400, 200, 20, "预算单位审核：");
				LODOP.ADD_PRINT_TEXT(685, 700, 200, 20, "国库审核：");
			}
		}
	</script>
</s:if>
<s:if test="#session.deptNo == '003' && #session.postNo == '002'">
	<script type="text/javascript" src="js/print_plugin/LodopFuncs.js"></script>
	<object id="LODOP_OB"
		classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
		<embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed>
	</object>
	<script type="text/javascript">
		var LODOP; //声明为全局变量

		function print_PaymentVouchers_Preview() {

			LODOP = getLodop(document.getElementById('LODOP_OB'), document
					.getElementById('LODOP_EM'));
			LODOP.PRINT_INIT("打印支付凭证");

			LODOP.SET_PRINT_PAGESIZE(1, 2820, 1010, "");
			createAllPages();

		}

		function createAllPages() {

			var now = new Date();
			var data = $("#apply_data");
			var select = data.jqGrid('getGridParam', 'selarrrow');
			var applyNoList = "";
			$.each(select, function(i, n) {
				var ret = data.jqGrid('getRowData', n);
				applyNoList += ret.applyNo + ":";

			});

			$.ajax({
				type : "post",
				url : "apply/printPaymentVouchers.action",
				data : {
					"applyNos" : applyNoList
				},

				success : function(data, textStatus) {
					fillData(data);
					LODOP.PREVIEW();
				},
				complete : function(XMLHttpRequest, textStatus) {
				},
				error : function() {
				}
			});

			function fillData(data) {
				var obj = eval(data);
				var paymentVouchers = obj.paymentVouchers[0];
				LODOP.ADD_PRINT_TEXT(64, 146, 60, 20, now.getFullYear());
				LODOP.ADD_PRINT_TEXT(64, 226, 30, 20, now.getMonth() + 1);
				LODOP.ADD_PRINT_TEXT(64, 268, 30, 20, now.getDate());

				LODOP.ADD_PRINT_TEXT(29, 625, 100, 20, paymentVouchers.applyNo);
				LODOP.ADD_PRINT_TEXT(47, 625, 100, 20,
						paymentVouchers.fundPropose);
				LODOP.ADD_PRINT_TEXT(65, 625, 100, 20,
						paymentVouchers.budgetType);

				LODOP.ADD_PRINT_TEXT(86, 189, 205, 20, "静宁县惠农专项资金特设专户");
				LODOP.ADD_PRINT_TEXT(106, 189, 205, 20, "27060600000427104");
				LODOP.ADD_PRINT_TEXT(126, 189, 205, 20, "中国人民银行静宁县支行");

				LODOP.ADD_PRINT_TEXT(86, 486, 235, 20, "国库待结算款项静宁县惠农补贴发放户");
				LODOP.ADD_PRINT_TEXT(106, 486, 235, 20, "3710604");
				LODOP.ADD_PRINT_TEXT(126, 486, 235, 20, "中国人民银行静宁县支行");

				LODOP.ADD_PRINT_TEXT(146, 189, 205, 20,
						paymentVouchers.budgetUnitLV0);
				LODOP.ADD_PRINT_TEXT(167, 189, 205, 20,
						paymentVouchers.budgetUnitLV1);

				LODOP.ADD_PRINT_TEXT(188, 189, 94, 20,
						paymentVouchers.payMethod);
				LODOP.ADD_PRINT_TEXT(188, 343, 52, 20,
						paymentVouchers.settleMethod);

				LODOP
						.ADD_PRINT_TEXT(210, 188, 300, 20,
								paymentVouchers.purpose);
				LODOP.ADD_PRINT_TEXT(230, 188, 205, 20,
						paymentVouchers.budgetItem);

				LODOP.ADD_PRINT_TEXT(147, 487, 235, 20,
						paymentVouchers.functionTypeLV0);
				LODOP.ADD_PRINT_TEXT(189, 487, 235, 20,
						paymentVouchers.functionTypeLV1);
				LODOP.ADD_PRINT_TEXT(168, 487, 235, 20,
						paymentVouchers.functionTypeLV2);

				LODOP.ADD_PRINT_TEXT(210, 487, 235, 20,
						paymentVouchers.financialTypeLV0);
				LODOP.ADD_PRINT_TEXT(229, 487, 235, 20,
						paymentVouchers.financialTypeLV1);

				LODOP.ADD_PRINT_TEXT(262, 188, 270, 20, LODOP.FORMAT(
						"UpperMoney", paymentVouchers.money));
				LODOP.ADD_PRINT_TEXT(270, 459, 270, 20, "￥"
						+ (paymentVouchers.money) * 100);
				LODOP.SET_PRINT_STYLEA(0, "Alignment", 3);
				LODOP.SET_PRINT_STYLEA(0, "LetterSpacing", 10);

				LODOP.NewPageA();
			}

		}
	</script>
</s:if>

<div id="" class="func_title">搜索条件</div>
<div id="index_form" class="form search_index_form">
	<table>
		<tbody>
			<tr>
				<td><label class="field_name">指标文号:</label></td>
				<td><select id="index_no" class="field_value"
					name="idx.indexNo">
						<option value="">--请选择--</option>
				</select></td>
				<td><label class="field_name">发文日期:</label></td>
				<td><select id="paper_date" class="field_value"
					name="idx.paperDate">
						<option value="">--请选择--</option>
				</select></td>
			</tr>
			<tr>
				<td><label class="field_name">预算单位:</label></td>
				<td><select id="budget_unit" class="field_value"
					name="idx.budgetUnit">
						<option value="">--请选择--</option>
				</select></td>
				<td><label class="field_name">指标来源:</label></td>
				<td><select id="index_source" class="field_value"
					name="idx.indexSource">
						<option value="">--请选择--</option>
				</select></td>
				<td><label class="field_name">指标类型:</label></td>
				<td><select id="index_type" class="field_value" name="">
						<option value="">--请选择--</option>
				</select></td>
				<td><label class="field_name">资金性质:</label></td>
				<td><select id="fund_prop" class="field_value" name="">
						<option value="">--请选择--</option>
				</select></td>
			</tr>

			<tr>

				<td><label class="field_name">支付方式:</label></td>
				<td><select id="pay_method" class="field_value" name="">
						<option value="">--请选择--</option>
				</select></td>
				<td><label class="field_name">预算项目:</label></td>
				<td><select id="budget_item" class="field_value" name="">
						<option value="">--请选择--</option>
				</select></td>
				<td><label class="field_name">功能分类:</label></td>
				<td><select id="func_type" class="field_value" name="">
						<option value="">--请选择--</option>
				</select></td>
				<td><label class="field_name">经济分类:</label></td>
				<td><select id="financial_type" class="field_value" name="">
						<option value="">--请选择--</option>
				</select></td>
			</tr>

		</tbody>
	</table>
	<div>
		<button id="search_index_submit">查找</button>
		<button id="search_index_reset">清除</button>
	</div>
</div>
<div id="" class="func_title">已审核申请信息</div>
<s:if test="#session.deptNo gt '200' && #session.postNo == '002'">
	<button id="print_apply" class="oper_btn" onclick="print_Apply_Preview()">打印支付申请书</button>
</s:if>
<s:if test="#session.deptNo == '003' && #session.postNo == '002'">
	<button id="print_pay" class="oper_btn" onclick="print_PaymentVouchers_Preview()">打印支付凭证</button>
	<button id="submit_pay" class="oper_btn">提交银行</button>
</s:if>
<table id="apply_data"></table>
<div id="apply_data_pager"></div>